#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=2100000;
int f[maxn+10],c[51],n,k,t;
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int main()
{
	scanf("%d",&t);
	for(int cas=1;cas<=t;cas++)
	{
		scanf("%d%d",&n,&k);
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			cin>>c[i];
			sum+=c[i];
		}
		sort(c+1,c+n+1);
		memset(f,0,sizeof(f));
		f[0]=1;
		for(int i=1;i<=n;i++)
			for(int j=sum;j>=0;j--)
				if(j-c[i]>=0)f[j]=max(f[j],f[j-c[i]]);
		int ans=0,p=0,next=n+1;
		for(int i=0;;i++)
				if(!f[i]){ans=i;break;}
		while(f[p])p++;
		sum=0;
		for(int i=1;i<=n;i++)
			if(c[i]<=p)sum+=c[i];
			else{next=i; break;}
		for(int i=1;i<=k;i++)
		{
			sum+=p;//insert p
			//find next position
			int e=2*p;
			for(int j=next;j<=n;j++)
				if(c[j]<=e)
				{
					sum+=c[j];
					next++;
					e=sum+1;
				}
			p=e;
		}
		
		cout<<"Case "<<cas<<":"<<endl<<p<<endl;
		if(cas!=t)cout<<endl;
	}
	return 0;
}
			



